package com.hh.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class PathValue {
    @RequestMapping("/{name}/{age}/path.do")
    /*使用@PathVariable可以获得url里面的值，如果参数名称和url里的不一样，可以指定，一样侧跳过*/
    public ModelAndView getPath(@PathVariable("name") String username,@PathVariable int age){
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("username",username);
        modelAndView.addObject("age",age);
        modelAndView.setViewName("pathvalue.jsp");
        return modelAndView;
    }
}
